package mysql

import "gorm.io/gorm"

type Goods struct {
	gorm.Model
	GoodsName  string  `gorm:"type:varchar(20);not null;comment:'商品名称'"`
	GoodsPrice float64 `gorm:"type:decimal(10,2);comment:'商品价格'"`
	GoodsNum   int     `gorm:"type:int(10);comment:'商品数量'"`
	GoodsState string  `gorm:"type:varchar(20);comment:'商品状态'"`
}

func (g *Goods) CheckGoods(goodsId int) error {
	return DB.Where("id = ?", goodsId).Limit(1).Find(&g).Error
}

func (g *Goods) Create() error {
	return DB.Create(&g).Error
}
